package com.GB26875_3_2011.message.parser;

import com.GB26875_3_2011.model.GB26875MessageBody;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 蒋仕国
 * @projectName GB26875_3_211
 * @ClassName GB26875Handler
 * @date 2025-01-13 08:54
 * @Description: TODO []
 */

public interface MessageBodyParser {
    // 解析消息体
    default List<GB26875MessageBody> parseBody(byte[] body) {
        if (body == null || body.length == 0) {
            return null;
        }
        ArrayList<GB26875MessageBody> bodysList =  new ArrayList<>();
        ByteBuf buffer = Unpooled.wrappedBuffer(body);
        while (buffer.readableBytes() > 0) {
            bodysList.add(parseBody(buffer));
        }
        return bodysList;
    }

    GB26875MessageBody parseBody(ByteBuf buffer);
}
